package su.demo.data;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import su.demo.service.StudentService;
import su.demo.service.TeacherService;

/**
 * @author SuZuQi
 * @title: DataSourceTest
 * @projectName ssm_multipledatasources
 * @description: TODO
 * @date 2019/9/9
 */
public class DataSourceTest {

    String applicationXml = "classpath:conf/spring-context.xml" ;



    @Test
    public void testStudent(){
            ApplicationContext context = new ClassPathXmlApplicationContext(applicationXml);
        StudentService studentService = context.getBean(StudentService.class);
        studentService.addStudent();
    }

    @Test
    public void testTeacher(){
        ApplicationContext context = new ClassPathXmlApplicationContext(applicationXml);
        StudentService studentService = context.getBean(StudentService.class);
        studentService.addStudent();
        TeacherService teacherService = context.getBean(TeacherService.class);
        int i = teacherService.addTeacher();
        System.out.println(i);
    }

}
